package ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.*;
import org.jdesktop.application.Application;

import controller.MobilePlanSellAndBillSystem;
import dto.PlanDTO;
import dto.ServiceDTO;
import dto.UserDTO;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MainApp extends javax.swing.JFrame {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	private JMenuItem helpMenuItem;
	private JMenu jMenu5;
	private JMenuItem jMenuItemAddItemToTitularPlan;
	private JMenuItem jMenuItemListPrePaidPlans;
	private JMenuItem jMenuItemListAdditionalPlans;
	private JMenuItem jMenuItemListTitularPlans;
	private JMenuItem jMenuItemAddPrePaidPlan;
	private JMenuItem jMenuItemAddAdditionalPlan;
	private JMenuItem jMenuItemAddTitularPlan;
	private JMenu jMenuPlans;
	private JMenuItem deleteServiceMenuItem;
	private JSeparator jSeparator1;
	private JMenuItem modifyServiceMenuItem;
	private JMenuItem listServiceMenuItem;
	private JMenuItem addServiceMenuItem;
	private JMenu jMenu4;
	private JMenuItem exitMenuItem;
	private JMenuItem jMenuItemInvoice;
	private JMenuItem jMenuItemAddPlan;
	private JMenuItem jMenuItemCreateLine;
	private JMenu jMenuLine;
	private JMenuItem jMenuItemAddItemToPrePaidPlan;
	private JMenuItem jMenuItemAddItemToAdditionalPlan;
	private JSeparator jSeparator2;
	private JMenuItem modifyClientMenuItem;
	private JMenuItem getClientMenuItem;
	private JMenuItem listClientMenuItem;
	private JMenuItem newFileMenuItem;
	private JMenuItem jMenuItemUseLine;
	private JMenuItem jMenuHistoricalPeriod;
	private JMenu jHistoricalBillsMenu;
	private JMenuItem jMenuItemGetLine;
	private JMenuItem jMenuItemChangeAdditionalLinePlan;
	private JMenuItem jMenuItemCreateAdditionalLine;
	private JMenu jMenuClient;
	private JMenuBar jMenuBar1;
	private MobilePlanSellAndBillSystem system;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MainApp inst = new MainApp();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
				
			}
		});
	}
	
	public MainApp() {
		super();
		initGUI();
		system = new MobilePlanSellAndBillSystem();
	}
	
	private void initGUI() {
		try {
			setSize(400, 300);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setEnabled(true);
			{
				jMenuBar1 = new JMenuBar();
				setJMenuBar(jMenuBar1);
				{
					jMenuClient = new JMenu();
					jMenuBar1.add(jMenuClient);
					jMenuClient.setText("Clientes");
					{
						newFileMenuItem = new JMenuItem();
						jMenuClient.add(newFileMenuItem);
						newFileMenuItem.setText("Create");
						newFileMenuItem.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								CreateClientsUI createClientUI = new CreateClientsUI(system);
								createClientUI.setVisible(true);								
							}
						});
					}
					{
						listClientMenuItem = new JMenuItem();
						jMenuClient.add(listClientMenuItem);
						listClientMenuItem.setText("List");
						listClientMenuItem.setName("listClientMenuItem");
						listClientMenuItem.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								ArrayList<UserDTO> users =  system.getUsers();
								GenericView view = new GenericView(users,true);
								view.setVisible(true);
								
							}
						 });

					}
					{
						getClientMenuItem = new JMenuItem();
						jMenuClient.add(getClientMenuItem);
						getClientMenuItem.setText("Get");
						getClientMenuItem.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								UserView userView = new UserView(system);
								userView.setVisible(true);
							}
						});
					}
					{
						modifyClientMenuItem = new JMenuItem();
						jMenuClient.add(modifyClientMenuItem);
						modifyClientMenuItem.setText("Modify");
						modifyClientMenuItem.setName("modifyClientMenuItem");
					}
					{
						jSeparator2 = new JSeparator();
						jMenuClient.add(jSeparator2);
					}
					{
						exitMenuItem = new JMenuItem();
						jMenuClient.add(exitMenuItem);
						exitMenuItem.setText("Delete");
						exitMenuItem.setName("exitMenuItem");
					}
				}
				{
					jMenu4 = new JMenu();
					jMenuBar1.add(jMenu4);
					jMenu4.setText("Services");
					{
						addServiceMenuItem = new JMenuItem();
						jMenu4.add(addServiceMenuItem);
						addServiceMenuItem.setText("Add");
						addServiceMenuItem.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								CreateServicesUI createServicesUI = new CreateServicesUI(system);
								createServicesUI.setVisible(true);								
							}
						});
					}
					{
						listServiceMenuItem = new JMenuItem();
						jMenu4.add(listServiceMenuItem);
						listServiceMenuItem.setText("List");
						listServiceMenuItem.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								ArrayList<ServiceDTO> services =  system.getServices();
								GenericView genericView = new GenericView(services);
								genericView.setVisible(true);								
							}
						});
					}
					{
						modifyServiceMenuItem = new JMenuItem();
						jMenu4.add(modifyServiceMenuItem);
						modifyServiceMenuItem.setText("Modify");
						modifyServiceMenuItem.setName("modifyServiceMenuItem");
					}
					{
						jSeparator1 = new JSeparator();
						jMenu4.add(jSeparator1);
					}
					{
						deleteServiceMenuItem = new JMenuItem();
						jMenu4.add(deleteServiceMenuItem);
						deleteServiceMenuItem.setText("Delete");
						deleteServiceMenuItem.setName("deleteServiceMenuItem");
					}
				}
//				{
//					jMenu5 = new JMenu();
//					jMenuBar1.add(jMenu5);
//					jMenu5.setText("Help");
//					{
//						helpMenuItem = new JMenuItem();
//						jMenu5.add(helpMenuItem);
//						helpMenuItem.setText("Help");
//					}
//				}
				{
					jMenuPlans = new JMenu();
					jMenuBar1.add(jMenuPlans);
					jMenuPlans.setText("Plans");
					{
						jMenuItemAddTitularPlan = new JMenuItem();
						jMenuPlans.add(jMenuItemAddTitularPlan);
						jMenuItemAddTitularPlan.setText("Add Titular Plan");
						jMenuItemAddTitularPlan.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								CreateTitularPlansUI createTitularPlansUI = new CreateTitularPlansUI(system);
								createTitularPlansUI.setVisible(true);								
							}
						});
						
					}
					{
						jMenuItemAddAdditionalPlan = new JMenuItem();
						jMenuPlans.add(jMenuItemAddAdditionalPlan);
						jMenuItemAddAdditionalPlan.setText("Add Additional Plan");
						jMenuItemAddAdditionalPlan.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								CreateAdditionalPlansUI createAdditionalPlansUI = new CreateAdditionalPlansUI(system);
								createAdditionalPlansUI.setVisible(true);								
							}
						});

					}
					{
						jMenuItemAddPrePaidPlan = new JMenuItem();
						jMenuPlans.add(jMenuItemAddPrePaidPlan);
						jMenuItemAddPrePaidPlan.setText("Add Pre Paid Plan");
						jMenuItemAddPrePaidPlan.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								CreatePrePaidPlansUI createPrePaidPlansUI = new CreatePrePaidPlansUI(system);
								createPrePaidPlansUI.setVisible(true);								
							}
						});
					}
					{
						jMenuItemListTitularPlans = new JMenuItem();
						jMenuPlans.add(jMenuItemListTitularPlans);
						jMenuItemListTitularPlans.setText("List Titular Plans");
						jMenuItemListTitularPlans.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								ArrayList<PlanDTO> plans =  system.getTitularPlans();
								ListPlanView listPlanView = new ListPlanView(plans);
								listPlanView.setVisible(true);									
							}
						});
					}
					{
						jMenuItemListAdditionalPlans = new JMenuItem();
						jMenuPlans.add(jMenuItemListAdditionalPlans);
						jMenuItemListAdditionalPlans.setText("List tAdditional Plans");
						jMenuItemListAdditionalPlans.setName("jMenuItemListAdditionalPlans");
						jMenuItemListAdditionalPlans.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								ArrayList<PlanDTO> plans =  system.getAdditionalPlans();
								ListPlanView listPlanView = new ListPlanView(plans);
								listPlanView.setVisible(true);									
							}
						});
					}
					{
						jMenuItemListPrePaidPlans = new JMenuItem();
						jMenuPlans.add(jMenuItemListPrePaidPlans);
						jMenuItemListPrePaidPlans.setText("List Pre paid Plans");
						jMenuItemListPrePaidPlans.setName("jMenuItemListPrePaidPlans");
						jMenuItemListPrePaidPlans.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								ArrayList<PlanDTO> plans =  system.getPrepaidPlans();
								ListPlanView listPlanView = new ListPlanView(plans);
								listPlanView.setVisible(true);									
							}
						});						
					}
					{
						jMenuItemAddItemToTitularPlan = new JMenuItem();
						jMenuPlans.add(jMenuItemAddItemToTitularPlan);
						jMenuItemAddItemToTitularPlan.setText("AddItemToTitularPlan");
						jMenuItemAddItemToTitularPlan.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								AddItemToPlanUI addItemToPlanUI = new AddItemToPlanUI(system);
								addItemToPlanUI.AddItemToTitularPlanUI();
								addItemToPlanUI.setVisible(true);								
							}
						});
					}
					{
						jMenuItemAddItemToAdditionalPlan = new JMenuItem();
						jMenuPlans.add(jMenuItemAddItemToAdditionalPlan);
						jMenuItemAddItemToAdditionalPlan.setText("AddItemToAdditionalPlan");
						jMenuItemAddItemToAdditionalPlan.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								AddItemToPlanUI addItemToPlanUI = new AddItemToPlanUI(system);
								addItemToPlanUI.AddItemToAdditionalPlanUI();
								addItemToPlanUI.setVisible(true);								
							}
						});
					}
					{
						jMenuItemAddItemToPrePaidPlan = new JMenuItem();
						jMenuPlans.add(jMenuItemAddItemToPrePaidPlan);
						jMenuItemAddItemToPrePaidPlan.setText("Add Item To Pre Paid Plan");
						jMenuItemAddItemToPrePaidPlan.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								AddItemToPlanUI addItemToPlanUI = new AddItemToPlanUI(system);
								addItemToPlanUI.AddItemToPrePaidPlanUI();
								addItemToPlanUI.setVisible(true);								
							}
						});
					}
				}
				{
					jMenuLine = new JMenu();
					jMenuBar1.add(jMenuLine);
					jMenuLine.setText("Line");
					{
						jMenuItemCreateLine = new JMenuItem();
						jMenuLine.add(jMenuItemCreateLine);
						jMenuItemCreateLine.setText("Create");
						jMenuItemCreateLine.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								CreateTitularLineUI createLineUI = new CreateTitularLineUI(system);
								createLineUI.setVisible(true);								
							}
						});
					}
					{
						jMenuItemCreateAdditionalLine = new JMenuItem();
						jMenuLine.add(jMenuItemCreateAdditionalLine);
						jMenuItemCreateAdditionalLine.setText("Create Additional Line");
						jMenuItemCreateAdditionalLine.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								CreateAdditionalLineUI createAdditionalLineUI = new CreateAdditionalLineUI(system);
								createAdditionalLineUI.setVisible(true);								
							}
						});
					}
					{
						jMenuItemAddPlan = new JMenuItem();
						jMenuLine.add(jMenuItemAddPlan);
						jMenuItemAddPlan.setText("Add Plan To Line");
						jMenuItemAddPlan.setName("jMenuItemAddPlan");
					}
					{
						jMenuItemInvoice = new JMenuItem();
						jMenuLine.add(jMenuItemInvoice);
						jMenuItemInvoice.setText("Invoice");
						jMenuItemInvoice.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								InvoiceUI invoiceUI = new InvoiceUI(system);
								invoiceUI.setVisible(true);								
							}
						});
					}
					{
						jMenuItemChangeAdditionalLinePlan = new JMenuItem();
						jMenuLine.add(jMenuItemChangeAdditionalLinePlan);
						jMenuItemChangeAdditionalLinePlan.setText("Change Additional Line Plan");
						jMenuItemChangeAdditionalLinePlan.setName("jMenuItemChangeAdditionalLinePlan");

					}
					{
						jMenuItemGetLine = new JMenuItem();
						jMenuLine.add(jMenuItemGetLine);
						jMenuItemGetLine.setText("Get Line");
						jMenuItemGetLine.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								LineView lineView = new LineView(system);
								lineView.setVisible(true);								
							}
						});
					}
					{
						jMenuItemUseLine = new JMenuItem();
						jMenuLine.add(jMenuItemUseLine);
						jMenuItemUseLine.setText("Use Line");
						jMenuItemUseLine.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								UseLineUI useLineUI = new UseLineUI(system);
								useLineUI.setVisible(true);								
							}
						});
					}

				}
				{
					jHistoricalBillsMenu = new JMenu();
					jMenuBar1.add(jHistoricalBillsMenu);
					jHistoricalBillsMenu.setText("Historical Bills Menu");
					jHistoricalBillsMenu.setName("jHistoricalBillsMenu");
					{
						jMenuHistoricalPeriod = new JMenuItem();
						jHistoricalBillsMenu.add(jMenuHistoricalPeriod);						
						jMenuHistoricalPeriod.setName("jMenuHistoricalPeriod");
						jMenuHistoricalPeriod.setText("Per Period");
						jMenuHistoricalPeriod.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) 
							{
								SearchHistoricalsBillsUI historical = new SearchHistoricalsBillsUI(system);
								historical.setVisible(true);								
							}
						});
					}
				}
			}
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(getContentPane());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
